//
//  YKTitleButton.m
//  youkan
//
//  Created by mac mini on 16/2/25.
//  Copyright © 2016年 Honsintech. All rights reserved.
//

#import "YKTitleButton.h"

@implementation YKTitleButton

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [self setBackgroundImage:[UIImage imageWithStretchableName:@"navigationbar_filter_background_highlighted"] forState:UIControlStateHighlighted];
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    if (!self.currentImage)  return;
//    CGFloat x = self.imageView.x;
//    self.titleLabel.x= x;
    self.imageView.x =CGRectGetMaxX(self.titleLabel.frame);
}
-(void)setTitle:(NSString *)title forState:(UIControlState)state{
    [super setTitle:title forState:state];
//!>   让view的size包裹内容
    [self sizeToFit];
}
-(void)setImage:(UIImage *)image forState:(UIControlState)state{
    [super setImage:image forState:state];
    [self sizeToFit];
}
//!>  空实现，点击不会高亮
-(void)setHighlighted:(BOOL)highlighted{
}

@end
